//
//  HSYCustomArcLayer.m
//  CustomNavigationController
//
//  Created by key on 2017/2/22.
//  Copyright © 2017年 huangsongyao. All rights reserved.
//

#import "HSYCustomArcLayer.h"
#import "UIView+Frame.h"
#import "HSYCustomArcLayer+Bezier.h"

#define DEFAULT_LINE_WIDTH              4.0f

@implementation HSYCustomArcLayer

- (instancetype)initWithLayer:(HSYCustomArcLayer *)layer
{
    if (self = [super initWithLayer:layer]) {
        self.progress = layer.progress;
    }
    return self;
}

- (void)drawInContext:(CGContextRef)ctx
{
    //使用贝塞尔曲线画出动态效果
    [self drawBezierPathByProgress:self.progress
                         lineWidth:(self.lineWidth > 0 ? self.lineWidth : DEFAULT_LINE_WIDTH)
                       strokeColor:[UIColor blackColor]
                         inContext:ctx];
}

+ (BOOL)needsDisplayForKey:(NSString *)key
{
    if ([key isEqualToString:PROGRESS_PROPERTY]) {
        return YES;
    }
    return [super needsDisplayForKey:key];
}

@end
